package com.yao.yaoojbackendquestionservice.controller.inner;

import com.yao.yaoojbackendmodel.model.entity.Question;
import com.yao.yaoojbackendmodel.model.entity.QuestionSubmit;
import com.yao.yaoojbackendquestionservice.service.QuestionService;
import com.yao.yaoojbackendquestionservice.service.QuestionSubmitService;
import com.yao.yaoojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

//该服务仅内部调用，不是给前端的
@RestController
@RequestMapping("/inner")
public class QuestioninnerController implements QuestionFeignClient {

    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionSubmitService questionSubmitService;

    @GetMapping("/get/id")
    @Override
    public Question getQuestionById (@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    }

    @GetMapping("/question_submit/get/id")
    @Override
    public QuestionSubmit getquestionSubmitById(@RequestParam("questionSubmitId") long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }

    @PostMapping("/question_submit/update")
    @Override
    public Boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }
}
